if(typeof links==="undefined"){links={}}if(typeof google==="undefined"){google=undefined}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(b){for(var a=0;a3){d.group=3}if(b>4){d.className=4}if(b>5){d.editable=5}if(b>6){d.type=6}}return d};links.Timeline.prototype.setData=function(e){this.unselectItem();if(!e){e=[]}this.stackCancelAnimation();this.clearItems();this.data=e;var b=this.items;this.deleteGroups();if(google&&google.visualization&&e instanceof google.visualization.DataTable){var f=links.Timeline.mapColumnIds(e);for(var g=0,d=e.getNumberOfRows();g0){d.addRows(g)}var f=links.Timeline.mapColumnIds(d);for(a in i){if(i.hasOwnProperty(a)){var b=f[a];if(b==undefined){var h=i[a];var c="string";if(typeof(h)=="number"){c="number"}else{if(typeof(h)=="boolean"){c="boolean"}else{if(h instanceof Date){c="datetime"}}}b=d.addColumn(c,a)}d.setValue(e,b,i[a])}}}else{if(links.Timeline.isArray(d)){var k=d[e];if(k==undefined){k={};d[e]=k}for(a in i){if(i.hasOwnProperty(a)){k[a]=i[a]}}}else{throw"Cannot update data, unknown type of data"}}};links.Timeline.prototype.getItemIndex=function(f){var g=f,k=this.dom,h=k.items.frame,b=this.items,c=undefined;while(g.parentNode&&g.parentNode!==h){g=g.parentNode}if(g.parentNode===h){for(var d=0,a=b.length;da.valueOf()){b=new Date(a.valueOf())}this.applyRange(f,b);if(e==undefined||e==true){this.render({animate:false})}else{this.recalcConversion()}};links.Timeline.prototype.setVisibleChartRangeAuto=function(){if(this.options&&(this.options.start||this.options.end)){this.setVisibleChartRange(this.options.start,this.options.end)}else{var a=this.getDataRange(true);this.setVisibleChartRange(a.min,a.max)}};links.Timeline.prototype.setVisibleChartRangeNow=function(){var a=new Date();var b=(this.end.valueOf()-this.start.valueOf());var d=new Date(a.valueOf()-b/2);var c=new Date(d.valueOf()+b);this.setVisibleChartRange(d,c)};links.Timeline.prototype.getVisibleChartRange=function(){return{start:new Date(this.start.valueOf()),end:new Date(this.end.valueOf())}};links.Timeline.prototype.getDataRange=function(b){var g=this.items,d=undefined,h=undefined;if(g){for(var f=0,e=g.length;f0){this.render({animate:i?i.animate:undefined,renderTimesLeft:(c-1)})}}};links.Timeline.prototype.repaint=function(){var b=this.repaintFrame();var a=this.repaintAxis();var d=this.repaintGroups();var c=this.repaintItems();this.repaintCurrentTime();this.repaintCustomTime();return(b||a||d||c)};links.Timeline.prototype.reflowFrame=function(){var f=this.dom,d=this.options,e=this.size,b=false;var a=f.frame?f.frame.offsetWidth:0,c=f.frame?f.frame.clientHeight:0;b=b||(e.frameWidth!==a);b=b||(e.frameHeight!==c);e.frameWidth=a;e.frameHeight=c;return b};links.Timeline.prototype.repaintFrame=function(){var b=false,d=this.dom,i=this.options,h=this.size;if(!d.frame){d.frame=document.createElement("DIV");d.frame.className="timeline-frame ui-widget ui-widget-content ui-corner-all";d.container.appendChild(d.frame);b=true}var g=i.autoHeight?(h.actualHeight+"px"):(i.height||"100%");var a=i.width||"100%";b=b||(d.frame.style.height!=g);b=b||(d.frame.style.width!=a);d.frame.style.height=g;d.frame.style.width=a;if(!d.content){d.content=document.createElement("DIV");d.content.className="timeline-content";d.frame.appendChild(d.content);var e=document.createElement("DIV");e.style.position="absolute";e.style.left="0px";e.style.top="0px";e.style.height="100%";e.style.width="0px";d.content.appendChild(e);d.contentTimelines=e;var c=this.eventParams,f=this;if(!c.onMouseDown){c.onMouseDown=function(k){f.onMouseDown(k)};links.Timeline.addEventListener(d.content,"mousedown",c.onMouseDown)}if(!c.onTouchStart){c.onTouchStart=function(k){f.onTouchStart(k)};links.Timeline.addEventListener(d.content,"touchstart",c.onTouchStart)}if(!c.onMouseWheel){c.onMouseWheel=function(k){f.onMouseWheel(k)};links.Timeline.addEventListener(d.content,"mousewheel",c.onMouseWheel)}if(!c.onDblClick){c.onDblClick=function(k){f.onDblClick(k)};links.Timeline.addEventListener(d.content,"dblclick",c.onDblClick)}b=true}d.content.style.left=h.contentLeft+"px";d.content.style.top="0px";d.content.style.width=h.contentWidth+"px";d.content.style.height=h.frameHeight+"px";this.repaintNavigation();return b};links.Timeline.prototype.reflowAxis=function(){var h=false,g=this.dom,n=this.options,m=this.size,k=g.axis;var i=(k&&k.characterMinor)?k.characterMinor.clientWidth:0,f=(k&&k.characterMinor)?k.characterMinor.clientHeight:0,b=(k&&k.characterMajor)?k.characterMajor.clientWidth:0,e=(k&&k.characterMajor)?k.characterMajor.clientHeight:0,d=(n.showMinorLabels?f:0)+(n.showMajorLabels?e:0);var a=n.axisOnTop?0:m.frameHeight-d,c=n.axisOnTop?d:a;h=h||(m.axis.top!==a);h=h||(m.axis.line!==c);h=h||(m.axis.height!==d);m.axis.top=a;m.axis.line=c;m.axis.height=d;m.axis.labelMajorTop=n.axisOnTop?0:c+(n.showMinorLabels?f:0);m.axis.labelMinorTop=n.axisOnTop?(n.showMajorLabels?e:0):c;m.axis.lineMinorTop=n.axisOnTop?m.axis.labelMinorTop:0;m.axis.lineMinorHeight=n.showMajorLabels?m.frameHeight-e:m.frameHeight;if(k&&k.minorLines&&k.minorLines.length){m.axis.lineMinorWidth=k.minorLines[0].offsetWidth}else{m.axis.lineMinorWidth=1}if(k&&k.majorLines&&k.majorLines.length){m.axis.lineMajorWidth=k.majorLines[0].offsetWidth}else{m.axis.lineMajorWidth=1}h=h||(m.axis.characterMinorWidth!==i);h=h||(m.axis.characterMinorHeight!==f);h=h||(m.axis.characterMajorWidth!==b);h=h||(m.axis.characterMajorHeight!==e);m.axis.characterMinorWidth=i;m.axis.characterMinorHeight=f;m.axis.characterMajorWidth=b;m.axis.characterMajorHeight=e;var l=Math.max(m.frameHeight-d,0);m.contentLeft=n.groupsOnRight?0:m.groupsWidth;m.contentWidth=Math.max(m.frameWidth-m.groupsWidth,0);m.contentHeight=l;return h};links.Timeline.prototype.repaintAxis=function(){var f=false,i=this.dom,r=this.options,q=this.size,e=this.step;var g=i.axis;if(!g){g={};i.axis=g}if(!q.axis.properties){q.axis.properties={}}if(!g.minorTexts){g.minorTexts=[]}if(!g.minorLines){g.minorLines=[]}if(!g.majorTexts){g.majorTexts=[]}if(!g.majorLines){g.majorLines=[]}if(!g.frame){g.frame=document.createElement("DIV");g.frame.style.position="absolute";g.frame.style.left="0px";g.frame.style.top="0px";i.content.appendChild(g.frame)}i.content.removeChild(g.frame);g.frame.style.width=(q.contentWidth)+"px";g.frame.style.height=(q.axis.height)+"px";var d=this.screenToTime(0);var h=this.screenToTime(q.contentWidth);if(q.axis.characterMinorWidth){this.minimumStep=this.screenToTime(q.axis.characterMinorWidth*6)-this.screenToTime(0);e.setRange(d,h,this.minimumStep)}var o=this.repaintAxisCharacters();f=f||o;this.repaintAxisStartOverwriting();e.start();var a=undefined;var l=0;while(!e.end()&&l<1000){l++;var p=e.getCurrent(),n=this.timeToScreen(p),k=e.isMajor();if(r.showMinorLabels){this.repaintAxisMinorText(n,e.getLabelMinor(r))}if(k&&r.showMajorLabels){if(n>0){if(a==undefined){a=n}this.repaintAxisMajorText(n,e.getLabelMajor(r))}this.repaintAxisMajorLine(n)}else{this.repaintAxisMinorLine(n)}e.next()}if(r.showMajorLabels){var c=this.screenToTime(0),m=this.step.getLabelMajor(r,c),b=m.length*q.axis.characterMajorWidth+10;if(a==undefined||be){var c=l[e];a.removeChild(c);l.splice(e,1)}var d=b.axis.minorLines;e=i.minorLineNum;while(d.length>e){var f=d[e];a.removeChild(f);d.splice(e,1)}var m=b.axis.majorTexts;e=i.majorTextNum;while(m.length>e){var h=m[e];a.removeChild(h);m.splice(e,1)}var g=b.axis.majorLines;e=i.majorLineNum;while(g.length>e){var k=g[e];a.removeChild(k);g.splice(e,1)}};links.Timeline.prototype.repaintAxisHorizontal=function(){var e=this.dom.axis,d=this.size,c=this.options;var a=(c.showMinorLabels||c.showMajorLabels);if(a){if(!e.backgroundLine){var f=document.createElement("DIV");f.className="timeline-axis";f.style.position="absolute";f.style.left="0px";f.style.width="100%";f.style.border="none";e.frame.insertBefore(f,e.frame.firstChild);e.backgroundLine=f}if(e.backgroundLine){e.backgroundLine.style.top=d.axis.top+"px";e.backgroundLine.style.height=d.axis.height+"px"}}else{if(e.backgroundLine){e.frame.removeChild(e.backgroundLine);delete e.backgroundLine}}if(a){if(e.line){var b=e.frame.removeChild(e.line);e.frame.appendChild(b)}else{var b=document.createElement("DIV");b.className="timeline-axis";b.style.position="absolute";b.style.left="0px";b.style.width="100%";b.style.height="0px";e.frame.appendChild(b);e.line=b}e.line.style.top=d.axis.line+"px"}else{if(e.line&&e.line.parentElement){e.frame.removeChild(e.line);delete e.line}}};links.Timeline.prototype.repaintAxisMinorText=function(h,i){var k=this.size,b=this.dom,e=k.axis.properties,a=b.axis.frame,g=b.axis.minorTexts,c=e.minorTextNum,f;if(c0)||(k.update.length>0)||(k.hide.length>0);while(o=k.show.shift()){o.showDOM(a);o.getImageUrls(c);b.push(o)}while(o=k.update.shift()){o.updateDOM(a);o.getImageUrls(c);l=this.renderedItems.indexOf(o);if(l==-1){b.push(o)}}while(o=k.hide.shift()){o.hideDOM(a);l=this.renderedItems.indexOf(o);if(l!=-1){b.splice(l,1)}}b.forEach(function(i){i.updatePosition(n)});this.repaintDeleteButton();this.repaintDragAreas();f.content.appendChild(a);if(c.length){var m=function(){n.render()};var e=false;links.imageloader.loadAll(c,m,e)}return d};links.Timeline.prototype.reflowGroups=function(){var f=false,n=this.options,m=this.size,d=this.dom;var k=0;var b=this.groups;var g=this.dom.groups?this.dom.groups.labels:[];for(var e=0,c=b.length;e-k.contentWidth&&h<2*k.contentWidth);e.currentTime.style.display=d?"":"none";e.currentTime.style.left=h+"px";e.currentTime.title="Current time: "+f;if(this.currentTimeTimer!=undefined){clearTimeout(this.currentTimeTimer);delete this.currentTimeTimer}var i=this;var g=function(){i.repaintCurrentTime()};var c=1/this.conversion.factor/2;if(c<30){c=30}this.currentTimeTimer=setTimeout(g,c)};links.Timeline.prototype.repaintCustomTime=function(){var c=this.options,g=this.dom,d=this.size;if(!c.showCustomTime){if(g.customTime){g.contentTimelines.removeChild(g.customTime);delete g.customTime}return}if(!g.customTime){var b=document.createElement("DIV");b.className="timeline-customtime";b.style.position="absolute";b.style.top="0px";b.style.height="100%";var e=document.createElement("DIV");e.style.position="relative";e.style.top="0px";e.style.left="-10px";e.style.height="100%";e.style.width="20px";b.appendChild(e);g.contentTimelines.appendChild(b);g.customTime=b;this.customTime=new Date()}var a=this.timeToScreen(this.customTime),f=(a>-d.contentWidth&&a<2*d.contentWidth);g.customTime.style.display=f?"":"none";g.customTime.style.left=a+"px";g.customTime.title="Time: "+this.customTime};links.Timeline.prototype.repaintDeleteButton=function(){var d=this,g=this.dom,f=g.items.frame;var h=g.items.deleteButton;if(!h){h=document.createElement("DIV");h.className="timeline-navigation-delete";h.style.position="absolute";f.appendChild(h);g.items.deleteButton=h}var a=(this.selection&&this.selection.index!==undefined)?this.selection.index:-1,c=(this.selection&&this.selection.index!==undefined)?this.items[a]:undefined;if(c&&c.rendered&&this.isEditable(c)){var b=c.getRight(this),e=c.top;h.style.left=b+"px";h.style.top=e+"px";h.style.display="";f.removeChild(h);f.appendChild(h)}else{h.style.display="none"}};links.Timeline.prototype.repaintDragAreas=function(){var k=this,m=this.options,d=this.dom,a=this.dom.items.frame;var c=d.items.dragLeft;if(!c){c=document.createElement("DIV");c.className="timeline-event-range-drag-left";c.style.position="absolute";a.appendChild(c);d.items.dragLeft=c}var e=d.items.dragRight;if(!e){e=document.createElement("DIV");e.className="timeline-event-range-drag-right";e.style.position="absolute";a.appendChild(e);d.items.dragRight=e}var f=(this.selection&&this.selection.index!==undefined)?this.selection.index:-1,l=(this.selection&&this.selection.index!==undefined)?this.items[f]:undefined;if(l&&l.rendered&&this.isEditable(l)&&(l instanceof links.Timeline.ItemRange||l instanceof links.Timeline.ItemFloatingRange)){var b=l.getLeft(this),h=l.getRight(this),g=l.top,i=l.height;c.style.left=b+"px";c.style.top=g+"px";c.style.width=m.dragAreaWidth+"px";c.style.height=i+"px";c.style.display="";a.removeChild(c);a.appendChild(c);e.style.left=(h-m.dragAreaWidth)+"px";e.style.top=g+"px";e.style.width=m.dragAreaWidth+"px";e.style.height=i+"px";e.style.display="";a.removeChild(e);a.appendChild(e)}else{c.style.display="none";e.style.display="none"}};links.Timeline.prototype.repaintNavigation=function(){var q=this,r=this.options,i=this.dom,e=i.frame,f=i.navBar;if(!f){var a=r.showButtonNew&&r.editable;var d=r.showNavigation&&(r.zoomable||r.moveable);if(d||a){f=document.createElement("DIV");f.style.position="absolute";f.className="timeline-navigation ui-widget ui-state-highlight ui-corner-all";if(r.groupsOnRight){f.style.left="10px"}else{f.style.right="10px"}if(r.axisOnTop){f.style.bottom="10px"}else{f.style.top="10px"}i.navBar=f;e.appendChild(f)}if(a){f.addButton=document.createElement("DIV");f.addButton.className="timeline-navigation-new";f.addButton.title=r.CREATE_NEW_EVENT;var h=document.createElement("SPAN");h.className="ui-icon ui-icon-circle-plus";f.addButton.appendChild(h);var m=function(A){links.Timeline.preventDefault(A);links.Timeline.stopPropagation(A);var t=q.size.contentWidth;var s=t/2;var u=q.screenToTime(s);if(r.snapEvents){q.step.snap(u)}var z=r.NEW;var B=q.groups.length?q.groups[0].content:undefined;var y=true;q.addItem({start:u,content:z,group:B},y);var v=(q.items.length-1);q.selectItem(v);q.applyAdd=true;q.trigger("add");if(q.applyAdd){q.render({animate:false});q.selectItem(v)}else{q.deleteItem(v)}};links.Timeline.addEventListener(f.addButton,"mousedown",m);f.appendChild(f.addButton)}if(a&&d){links.Timeline.addClassName(f.addButton,"timeline-navigation-new-line")}if(d){if(r.zoomable){f.zoomInButton=document.createElement("DIV");f.zoomInButton.className="timeline-navigation-zoom-in";f.zoomInButton.title=this.options.ZOOM_IN;var p=document.createElement("SPAN");p.className="ui-icon ui-icon-circle-zoomin";f.zoomInButton.appendChild(p);var c=function(s){links.Timeline.preventDefault(s);links.Timeline.stopPropagation(s);q.zoom(0.4);q.trigger("rangechange");q.trigger("rangechanged")};links.Timeline.addEventListener(f.zoomInButton,"mousedown",c);f.appendChild(f.zoomInButton);f.zoomOutButton=document.createElement("DIV");f.zoomOutButton.className="timeline-navigation-zoom-out";f.zoomOutButton.title=this.options.ZOOM_OUT;var l=document.createElement("SPAN");l.className="ui-icon ui-icon-circle-zoomout";f.zoomOutButton.appendChild(l);var k=function(s){links.Timeline.preventDefault(s);links.Timeline.stopPropagation(s);q.zoom(-0.4);q.trigger("rangechange");q.trigger("rangechanged")};links.Timeline.addEventListener(f.zoomOutButton,"mousedown",k);f.appendChild(f.zoomOutButton)}if(r.moveable){f.moveLeftButton=document.createElement("DIV");f.moveLeftButton.className="timeline-navigation-move-left";f.moveLeftButton.title=this.options.MOVE_LEFT;var o=document.createElement("SPAN");o.className="ui-icon ui-icon-circle-arrow-w";f.moveLeftButton.appendChild(o);var n=function(s){links.Timeline.preventDefault(s);links.Timeline.stopPropagation(s);q.move(-0.2);q.trigger("rangechange");q.trigger("rangechanged")};links.Timeline.addEventListener(f.moveLeftButton,"mousedown",n);f.appendChild(f.moveLeftButton);f.moveRightButton=document.createElement("DIV");f.moveRightButton.className="timeline-navigation-move-right";f.moveRightButton.title=this.options.MOVE_RIGHT;var g=document.createElement("SPAN");g.className="ui-icon ui-icon-circle-arrow-e";f.moveRightButton.appendChild(g);var b=function(s){links.Timeline.preventDefault(s);links.Timeline.stopPropagation(s);q.move(0.2);q.trigger("rangechange");q.trigger("rangechanged")};links.Timeline.addEventListener(f.moveRightButton,"mousedown",b);f.appendChild(f.moveRightButton)}}}};links.Timeline.prototype.setCurrentTime=function(b){var a=new Date();this.clientTimeOffset=(b.valueOf()-a.valueOf());this.repaintCurrentTime()};links.Timeline.prototype.getCurrentTime=function(){var a=new Date();return new Date(a.valueOf()+this.clientTimeOffset)};links.Timeline.prototype.setCustomTime=function(a){this.customTime=new Date(a.valueOf());this.repaintCustomTime()};links.Timeline.prototype.getCustomTime=function(){return new Date(this.customTime.valueOf())};links.Timeline.prototype.setScale=function(b,a){this.step.setScale(b,a);this.render()};links.Timeline.prototype.setAutoScale=function(a){this.step.setAutoScale(a);this.render()};links.Timeline.prototype.redraw=function(){this.setData(this.data)};links.Timeline.prototype.checkResize=function(){this.render()};links.Timeline.prototype.isEditable=function(a){if(a){if(a.editable!=undefined){return a.editable}else{return this.options.editable}}return false};links.Timeline.prototype.recalcConversion=function(){this.conversion.offset=this.start.valueOf();this.conversion.factor=this.size.contentWidth/(this.end.valueOf()-this.start.valueOf())};links.Timeline.prototype.screenToTime=function(a){var b=this.conversion;return new Date(a/b.factor+b.offset)};links.Timeline.prototype.timeToScreen=function(b){var a=this.conversion;return(b.valueOf()-a.offset)*a.factor};links.Timeline.prototype.onTouchStart=function(c){var e=this.eventParams,b=this;if(e.touchDown){return}e.touchDown=true;e.zoomed=false;this.onMouseDown(c);if(!e.onTouchMove){e.onTouchMove=function(f){b.onTouchMove(f)};links.Timeline.addEventListener(document,"touchmove",e.onTouchMove)}if(!e.onTouchEnd){e.onTouchEnd=function(f){b.onTouchEnd(f)};links.Timeline.addEventListener(document,"touchend",e.onTouchEnd)}var d=links.Timeline.getTarget(c);var a=this.getItemIndex(d);e.doubleTapStartPrev=e.doubleTapStart;e.doubleTapStart=(new Date()).valueOf();e.doubleTapItemPrev=e.doubleTapItem;e.doubleTapItem=a;links.Timeline.preventDefault(c)};links.Timeline.prototype.onTouchMove=function(d){var g=this.eventParams;if(d.scale&&d.scale!==1){g.zoomed=true}if(!g.zoomed){this.onMouseMove(d)}else{if(this.options.zoomable){g.zoomed=true;var f=d.scale,b=(g.end.valueOf()-g.start.valueOf()),c=b/f,e=c-b,h=new Date(parseInt(g.start.valueOf()-e/2)),a=new Date(parseInt(g.end.valueOf()+e/2));this.setVisibleChartRange(h,a);this.trigger("rangechange")}}links.Timeline.preventDefault(d)};links.Timeline.prototype.onTouchEnd=function(d){var f=this.eventParams;var c=this;f.touchDown=false;if(f.zoomed){this.trigger("rangechanged")}if(f.onTouchMove){links.Timeline.removeEventListener(document,"touchmove",f.onTouchMove);delete f.onTouchMove}if(f.onTouchEnd){links.Timeline.removeEventListener(document,"touchend",f.onTouchEnd);delete f.onTouchEnd}this.onMouseUp(d);var g=500;var a=(new Date()).valueOf();var e=links.Timeline.getTarget(d);var b=this.getItemIndex(e);if(f.doubleTapStartPrev&&(a-f.doubleTapStartPrev)=1){D.moved=true}if(D.customTime){var o=this.timeToScreen(D.customTime);var q=o+t;this.customTime=this.screenToTime(q);this.repaintCustomTime();this.trigger("timechange")}else{if(D.editItem){var B=this.items[D.itemIndex],f,C;if(D.itemDragLeft&&e.timeChangeable){f=D.itemLeft+t;C=D.itemRight;B.start=this.screenToTime(f);if(e.snapEvents){this.step.snap(B.start);f=this.timeToScreen(B.start)}if(f>C){f=C;B.start=this.screenToTime(f)}this.trigger("change")}else{if(D.itemDragRight&&e.timeChangeable){f=D.itemLeft;C=D.itemRight+t;B.end=this.screenToTime(C);if(e.snapEvents){this.step.snap(B.end);C=this.timeToScreen(B.end)}if(C=1){g=0.9}if(g<=-1){g=-0.9}if(g<0){g=g/(1+g)}var e=(this.start.valueOf()-h);var d=(this.end.valueOf()-h);var a=new Date(this.start.valueOf()-e*g);var f=new Date(this.end.valueOf()-d*g);var c=(f.valueOf()-a.valueOf());var b=Number(this.options.zoomMin)||10;if(b<10){b=10}if(c>=b){this.applyRange(a,f,h);this.render({animate:this.options.animate&&this.options.animateZoom})}};links.Timeline.prototype.move=function(b){var d=(this.end.valueOf()-this.start.valueOf());var a=new Date(this.start.valueOf()+d*b);var c=new Date(this.end.valueOf()+d*b);this.applyRange(a,c);this.render()};links.Timeline.prototype.applyRange=function(b,e,a){var c=b.valueOf();var n=e.valueOf();var d=(n-c);var q=this.options;var k=1000*60*60*24*365;var h=Number(q.zoomMin)||10;if(h<10){h=10}var p=Number(q.zoomMax)||10000*k;if(p>10000*k){p=10000*k}if(p=m){var l=1000*60*60*24;m=g+l}if(p>(m-g)){p=(m-g)}if(h>(m-g)){h=(m-g)}}if(c>=n){n+=1000*60*60*24}if(dp){var o=(d-p);var i=a?(a.valueOf()-c)/d:0.5;c+=Math.round(o*i);n-=Math.round(o*(1-i))}if(g!=undefined){var o=(c-g);if(o<0){c-=o;n-=o}}if(m!=undefined){var o=(m-n);if(o<0){c+=o;n+=o}}this.start=new Date(c);this.end=new Date(n)};links.Timeline.prototype.confirmDeleteItem=function(a){this.applyDelete=true;if(!this.isSelected(a)){this.selectItem(a)}this.trigger("delete");if(this.applyDelete){this.deleteItem(a)}delete this.applyDelete};links.Timeline.prototype.deleteItem=function(a,c){if(a>=this.items.length){throw"Cannot delete row, index out of range"}if(this.selection&&this.selection.index!==undefined){if(this.selection.index==a){this.unselectItem()}else{if(this.selection.index>a){this.selection.index--}}}var b=this.items.splice(a,1)[0];this.renderQueue.hide.push(b);if(this.data){if(google&&google.visualization&&this.data instanceof google.visualization.DataTable){this.data.removeRow(a)}else{if(links.Timeline.isArray(this.data)){this.data.splice(a,1)}else{throw"Cannot delete row from data, unknown data type"}}}if(this.options.cluster){this.clusterGenerator.updateData()}if(!c){this.render()}};links.Timeline.prototype.deleteAllItems=function(){this.unselectItem();this.clearItems();this.deleteGroups();if(this.data){if(google&&google.visualization&&this.data instanceof google.visualization.DataTable){this.data.removeRows(0,this.data.getNumberOfRows())}else{if(links.Timeline.isArray(this.data)){this.data.splice(0,this.data.length)}else{throw"Cannot delete row from data, unknown data type"}}}if(this.options.cluster){this.clusterGenerator.updateData()}this.render()};links.Timeline.prototype.getGroupFromHeight=function(b){var c,d,a=this.groups;if(a.length){if(this.options.axisOnTop){for(c=a.length-1;c>=0;c--){d=a[c];if(b>d.top){return d}}}else{for(c=0;cd.top){return d}}}return d}return undefined};links.Timeline.Item=function(c,a){if(c){this.start=c.start;this.end=c.end;this.content=c.content;this.className=c.className;this.editable=c.editable;this.group=c.group;this.type=c.type}this.top=0;this.left=0;this.width=0;this.height=0;this.lineWidth=0;this.dotWidth=0;this.dotHeight=0;this.rendered=false;if(a){for(var b in a){if(a.hasOwnProperty(b)){this[b]=a[b]}}}};links.Timeline.Item.prototype.reflow=function(){return false};links.Timeline.Item.prototype.getImageUrls=function(a){if(this.dom){links.imageloader.filterImageUrls(this.dom,a)}};links.Timeline.Item.prototype.select=function(){};links.Timeline.Item.prototype.unselect=function(){};links.Timeline.Item.prototype.createDOM=function(){};links.Timeline.Item.prototype.showDOM=function(a){};links.Timeline.Item.prototype.hideDOM=function(a){};links.Timeline.Item.prototype.updateDOM=function(){};links.Timeline.Item.prototype.updatePosition=function(a){};links.Timeline.Item.prototype.isRendered=function(){return this.rendered};links.Timeline.Item.prototype.isVisible=function(b,a){return false};links.Timeline.Item.prototype.setPosition=function(b,a){};links.Timeline.Item.prototype.getLeft=function(a){return 0};links.Timeline.Item.prototype.getRight=function(a){return 0};links.Timeline.Item.prototype.getWidth=function(a){return this.width||0};links.Timeline.ItemBox=function(b,a){links.Timeline.Item.call(this,b,a)};links.Timeline.ItemBox.prototype=new links.Timeline.Item();links.Timeline.ItemBox.prototype.reflow=function(){var e=this.dom,c=e.dot.offsetHeight,d=e.dot.offsetWidth,a=e.line.offsetWidth,b=((this.dotHeight!=c)||(this.dotWidth!=d)||(this.lineWidth!=a));this.dotHeight=c;this.dotWidth=d;this.lineWidth=a;return b};links.Timeline.ItemBox.prototype.select=function(){var a=this.dom;links.Timeline.addClassName(a,"timeline-event-selected ui-state-active");links.Timeline.addClassName(a.line,"timeline-event-selected ui-state-active");links.Timeline.addClassName(a.dot,"timeline-event-selected ui-state-active")};links.Timeline.ItemBox.prototype.unselect=function(){var a=this.dom;links.Timeline.removeClassName(a,"timeline-event-selected ui-state-active");links.Timeline.removeClassName(a.line,"timeline-event-selected ui-state-active");links.Timeline.removeClassName(a.dot,"timeline-event-selected ui-state-active")};links.Timeline.ItemBox.prototype.createDOM=function(){var c=document.createElement("DIV");c.style.position="absolute";c.style.left=this.left+"px";c.style.top=this.top+"px";var b=document.createElement("DIV");b.className="timeline-event-content";b.innerHTML=this.content;c.appendChild(b);var d=document.createElement("DIV");d.style.position="absolute";d.style.width="0px";c.line=d;var a=document.createElement("DIV");a.style.position="absolute";a.style.width="0px";a.style.height="0px";c.dot=a;this.dom=c;this.updateDOM();return c};links.Timeline.ItemBox.prototype.showDOM=function(a){var b=this.dom;if(!b){b=this.createDOM()}if(b.parentNode!=a){if(b.parentNode){this.hideDOM()}a.appendChild(b);a.insertBefore(b.line,a.firstChild);a.appendChild(b.dot);this.rendered=true}};links.Timeline.ItemBox.prototype.hideDOM=function(){var a=this.dom;if(a){if(a.parentNode){a.parentNode.removeChild(a)}if(a.line&&a.line.parentNode){a.line.parentNode.removeChild(a.line)}if(a.dot&&a.dot.parentNode){a.dot.parentNode.removeChild(a.dot)}this.rendered=false}};links.Timeline.ItemBox.prototype.updateDOM=function(){var b=this.dom;if(b){var c=b.line;var a=b.dot;b.firstChild.innerHTML=this.content;b.className="timeline-event timeline-event-box ui-widget ui-state-default";c.className="timeline-event timeline-event-line ui-widget ui-state-default";a.className="timeline-event timeline-event-dot ui-widget ui-state-default";if(this.isCluster){links.Timeline.addClassName(b,"timeline-event-cluster ui-widget-header");links.Timeline.addClassName(c,"timeline-event-cluster ui-widget-header");links.Timeline.addClassName(a,"timeline-event-cluster ui-widget-header")}if(this.className){links.Timeline.addClassName(b,this.className);links.Timeline.addClassName(c,this.className);links.Timeline.addClassName(a,this.className)}}};links.Timeline.ItemBox.prototype.updatePosition=function(g){var e=this.dom;if(e){var c=g.timeToScreen(this.start),f=g.options.axisOnTop,a=g.size.axis.top,d=g.size.axis.height,h=(g.options.box&&g.options.box.align)?g.options.box.align:undefined;e.style.top=this.top+"px";if(h=="right"){e.style.left=(c-this.width)+"px"}else{if(h=="left"){e.style.left=(c)+"px"}else{e.style.left=(c-this.width/2)+"px"}}var i=e.line;var b=e.dot;i.style.left=(c-this.lineWidth/2)+"px";b.style.left=(c-this.dotWidth/2)+"px";if(f){i.style.top=d+"px";i.style.height=Math.max(this.top-d,0)+"px";b.style.top=(d-this.dotHeight/2)+"px"}else{i.style.top=(this.top+this.height)+"px";i.style.height=Math.max(a-this.top-this.height,0)+"px";b.style.top=(a-this.dotHeight/2)+"px"}}};links.Timeline.ItemBox.prototype.isVisible=function(b,a){if(this.cluster){return false}return(this.start>b)&&(this.start2*a){b=2*a}e.style.top=this.top+"px";e.style.left=d+"px";e.style.width=Math.max(b-d,1)+"px"}};links.Timeline.ItemRange.prototype.isVisible=function(b,a){if(this.cluster){return false}return(this.end>b)&&(this.start2*a){b=2*a}e.style.top=this.top+"px";e.style.left=d+"px";e.style.width=Math.max(b-d,1)+"px"}};links.Timeline.ItemFloatingRange.prototype.isVisible=function(b,a){if(this.cluster){return false}if(this.end&&this.start){return(this.end>b)&&(this.startb)}else{return true}}}};links.Timeline.ItemFloatingRange.prototype.setPosition=function(b,a){var c=this.dom;c.style.left=b+"px";c.style.width=(a-b)+"px";if(this.group){this.top=this.group.top;c.style.top=this.top+"px"}};links.Timeline.ItemFloatingRange.prototype.getLeft=function(a){if(this.start){return a.timeToScreen(this.start)}else{return 0}};links.Timeline.ItemFloatingRange.prototype.getRight=function(a){if(this.end){return a.timeToScreen(this.end)}else{return a.size.contentWidth}};links.Timeline.ItemFloatingRange.prototype.getWidth=function(a){return this.getRight(a)-this.getLeft(a)};links.Timeline.ItemDot=function(b,a){links.Timeline.Item.call(this,b,a)};links.Timeline.ItemDot.prototype=new links.Timeline.Item();links.Timeline.ItemDot.prototype.reflow=function(){var e=this.dom,c=e.dot.offsetHeight,d=e.dot.offsetWidth,b=e.content.offsetHeight,a=((this.dotHeight!=c)||(this.dotWidth!=d)||(this.contentHeight!=b));this.dotHeight=c;this.dotWidth=d;this.contentHeight=b;return a};links.Timeline.ItemDot.prototype.select=function(){var a=this.dom;links.Timeline.addClassName(a,"timeline-event-selected ui-state-active")};links.Timeline.ItemDot.prototype.unselect=function(){var a=this.dom;links.Timeline.removeClassName(a,"timeline-event-selected ui-state-active")};links.Timeline.ItemDot.prototype.createDOM=function(){var c=document.createElement("DIV");c.style.position="absolute";var b=document.createElement("DIV");b.className="timeline-event-content";c.appendChild(b);var a=document.createElement("DIV");a.style.position="absolute";a.style.width="0px";a.style.height="0px";c.appendChild(a);c.content=b;c.dot=a;this.dom=c;this.updateDOM();return c};links.Timeline.ItemDot.prototype.showDOM=function(a){var b=this.dom;if(!b){b=this.createDOM()}if(b.parentNode!=a){if(b.parentNode){this.hideDOM()}a.appendChild(b);this.rendered=true}};links.Timeline.ItemDot.prototype.hideDOM=function(){var a=this.dom;if(a){if(a.parentNode){a.parentNode.removeChild(a)}this.rendered=false}};links.Timeline.ItemDot.prototype.updateDOM=function(){if(this.dom){var b=this.dom;var a=b.dot;b.firstChild.innerHTML=this.content;b.className="timeline-event-dot-container";a.className="timeline-event timeline-event-dot ui-widget ui-state-default";if(this.isCluster){links.Timeline.addClassName(b,"timeline-event-cluster ui-widget-header");links.Timeline.addClassName(a,"timeline-event-cluster ui-widget-header")}if(this.className){links.Timeline.addClassName(b,this.className);links.Timeline.addClassName(a,this.className)}}};links.Timeline.ItemDot.prototype.updatePosition=function(a){var c=this.dom;if(c){var b=a.timeToScreen(this.start);c.style.top=this.top+"px";c.style.left=(b-this.dotWidth/2)+"px";c.content.style.marginLeft=(1.5*this.dotWidth)+"px";c.dot.style.top=((this.height-this.dotHeight)/2)+"px"}};links.Timeline.ItemDot.prototype.isVisible=function(b,a){if(this.cluster){return false}return(this.start>b)&&(this.start=this.items.length){throw"Cannot get item, index out of range"}var e=this.data,a;if(google&&google.visualization&&e instanceof google.visualization.DataTable){var f=links.Timeline.mapColumnIds(e);a={};for(var b in f){if(f.hasOwnProperty(b)){a[b]=this.data.getValue(c,f[b])}}}else{if(links.Timeline.isArray(this.data)){a=links.Timeline.clone(this.data[c])}else{throw"Unknown data type. DataTable or Array expected."}}var d=this.items[c];a.start=new Date(d.start.valueOf());if(d.end){a.end=new Date(d.end.valueOf())}a.content=d.content;if(d.group){a.group=this.getGroupName(d.group)}if(d.className){a.className=d.className}if(typeof d.editable!=="undefined"){a.editable=d.editable}if(d.type){a.type=d.type}return a};links.Timeline.prototype.getCluster=function(d){if(d>=this.clusters.length){throw"Cannot get cluster, index out of range"}var b={},a=this.clusters[d],f=a.items;b.start=new Date(a.start.valueOf());if(a.type){b.type=a.type}b.items=[];for(var e=0;eh.content){return 1}if(i.content0){if(g[0].row!=undefined){var e=g[0].row;if(this.items[e]){var h=this.items[e];this.selectItem(e);var a=h.start;var c=h.end;var i;if(c!=undefined){i=(c.valueOf()+a.valueOf())/2}else{i=a.valueOf()}var f=(this.end.valueOf()-this.start.valueOf()),d=new Date(i-f/2),b=new Date(i+f/2);this.setVisibleChartRange(d,b);return true}}}else{this.unselectItem()}return false};links.Timeline.prototype.getSelection=function(){var a=[];if(this.selection){if(this.selection.index!==undefined){a.push({row:this.selection.index})}else{a.push({cluster:this.selection.cluster})}}return a};links.Timeline.prototype.selectItem=function(a){this.unselectItem();this.selection=undefined;if(this.items[a]!=undefined){var c=this.items[a],b=c.dom;this.selection={index:a};if(c&&c.dom){if(this.isEditable(c)){c.dom.style.cursor="move"}c.select()}this.repaintDeleteButton();this.repaintDragAreas()}};links.Timeline.prototype.selectCluster=function(a){this.unselectItem();this.selection=undefined;if(this.clusters[a]!=undefined){this.selection={cluster:a};this.repaintDeleteButton();this.repaintDragAreas()}};links.Timeline.prototype.isSelected=function(a){return(this.selection&&this.selection.index==a)};links.Timeline.prototype.unselectItem=function(){if(this.selection&&this.selection.index!==undefined){var b=this.items[this.selection.index];if(b&&b.dom){var a=b.dom;a.style.cursor="";b.unselect()}this.selection=undefined;this.repaintDeleteButton();this.repaintDragAreas()}};links.Timeline.prototype.stackItems=function(b){if(b==undefined){b=false}var a=this.stack;if(!a){a={};this.stack=a}a.sortedItems=this.stackOrder(this.renderedItems);a.finalItems=this.stackCalculateFinal(a.sortedItems);if(b||a.timer){var d=this;var c=function(){var e=d.stackMoveOneStep(a.sortedItems,a.finalItems);d.repaint();if(!e){a.timer=setTimeout(c,30)}else{delete a.timer}};if(!a.timer){a.timer=setTimeout(c,30)}}else{this.stackMoveToFinal(a.sortedItems,a.finalItems)}};links.Timeline.prototype.stackCancelAnimation=function(){if(this.stack&&this.stack.timer){clearTimeout(this.stack.timer);delete this.stack.timer}};links.Timeline.prototype.getItemsByGroup=function(a){var d={};for(var b=0;bl)?1:-1);if(Math.abs(k)>4){a=k/4}var b=parseInt(l+a);if(b!=h){d=false}n.top=b;n.bottom=n.top+n.height}else{n.top=f.top;n.bottom=f.bottom}n.left=f.left;n.right=f.right}return d};links.Timeline.prototype.stackMoveToFinal=function(b,d){for(var c=0,a=d.length;c=g;c--){var d=h[c];if(k(e,d,b)){if(c!=a){return d}}}return undefined};links.Timeline.prototype.collision=function(b,a,c){if(c==undefined){c=0}return(b.left-ca.left&&b.top-ca.top)};links.Timeline.prototype.trigger=function(b){var a=null;switch(b){case"rangechange":case"rangechanged":a={start:new Date(this.start.valueOf()),end:new Date(this.end.valueOf())};break;case"timechange":case"timechanged":a={time:new Date(this.customTime.valueOf())};break}links.events.trigger(this,b,a);if(google&&google.visualization){google.visualization.events.trigger(this,b,a)}};links.Timeline.prototype.clusterItems=function(){if(!this.options.cluster){return}var b=this.clusterGenerator.getClusters(this.conversion.factor,this.options.clusterMaxItems);if(this.clusters!=b){var a=this.renderQueue;if(this.clusters){this.clusters.forEach(function(c){a.hide.push(c);c.items.forEach(function(d){d.cluster=undefined})})}b.forEach(function(c){c.items.forEach(function(d){d.cluster=c})});this.clusters=b}};links.Timeline.prototype.filterItems=function(){var a=this.renderQueue,d=(this.end-this.start),e=new Date(this.start.valueOf()-d),b=new Date(this.end.valueOf()+d);function c(f){f.forEach(function(g){var i=g.rendered;var h=g.isVisible(e,b);if(i!=h){if(i){a.hide.push(g)}if(h&&(a.show.indexOf(g)==-1)){a.show.push(g)}}})}c(this.items);if(this.clusters){c(this.clusters)}};links.Timeline.ClusterGenerator=function(a){this.timeline=a;this.clear()};links.Timeline.ClusterGenerator.prototype.clear=function(){this.items=[];this.groups={};this.clearCache()};links.Timeline.ClusterGenerator.prototype.clearCache=function(){this.cache={};this.cacheLevel=-1;this.cache[this.cacheLevel]=[]};links.Timeline.ClusterGenerator.prototype.setData=function(a,b){this.items=a||[];this.dataChanged=true;this.applyOnChangedLevel=true;if(b&&b.applyOnChangedLevel){this.applyOnChangedLevel=b.applyOnChangedLevel}};links.Timeline.ClusterGenerator.prototype.updateData=function(){this.dataChanged=true;this.applyOnChangedLevel=false};links.Timeline.ClusterGenerator.prototype.filterData=function(){var b=this.items||[];var a={};this.groups=a;b.forEach(function(d){var f=d.group?d.group.content:"";var e=a[f];if(!e){e=[];a[f]=e}e.push(d);if(d.start){if(d.end){d.center=(d.start.valueOf()+d.end.valueOf())/2}else{d.center=d.start.valueOf()}}});for(var c in a){if(a.hasOwnProperty(c)){a[c].sort(function(e,d){return(e.center-d.center)})}}this.dataChanged=false};links.Timeline.ClusterGenerator.prototype.getClusters=function(K,H){var a=-1,b=2,x=0;if(K>0){a=Math.round(Math.log(100/K)/Math.log(b));x=Math.pow(b,a)}if(this.dataChanged){var w=(a!=this.cacheLevel);var D=this.applyOnChangedLevel?w:true;if(D){this.clearCache();this.filterData()}}this.cacheLevel=a;var h=this.cache[a];if(!h){h=[];for(var q in this.groups){if(this.groups.hasOwnProperty(q)){var r=this.groups[q];var z=r.length;var G=0;while(G=0&&(J.center-r[E].center)=0&&(J.center-h[A].center)H){var n=v-H+1;var d=[];var t=undefined;var y=undefined;var F=undefined;var f=false;var g=0;var u=G;while(d.length'+g+" events";var o=J.group?J.group.content:undefined;if(f){I=this.timeline.createItem({start:new Date(y),end:new Date(F),content:B,group:o})}else{I=this.timeline.createItem({start:new Date(t),content:B,group:o})}I.isCluster=true;I.items=d;I.items.forEach(function(i){i.cluster=I});h.push(I);G+=n}else{delete J.cluster;G+=1}}}}this.cache[a]=h}return h};links.events=links.events||{listeners:[],indexOf:function(b){var d=this.listeners;for(var c=0,a=this.listeners.length;cthis._end.valueOf())};links.Timeline.StepDate.prototype.next=function(){var b=this.current.valueOf();if(this.current.getMonth()<6){switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current=new Date(this.current.valueOf()+this.step);break;case links.Timeline.StepDate.SCALE.SECOND:this.current=new Date(this.current.valueOf()+this.step*1000);break;case links.Timeline.StepDate.SCALE.MINUTE:this.current=new Date(this.current.valueOf()+this.step*1000*60);break;case links.Timeline.StepDate.SCALE.HOUR:this.current=new Date(this.current.valueOf()+this.step*1000*60*60);var a=this.current.getHours();this.current.setHours(a-(a%this.step));break;case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:this.current.setDate(this.current.getDate()+this.step);break;case links.Timeline.StepDate.SCALE.MONTH:this.current.setMonth(this.current.getMonth()+this.step);break;case links.Timeline.StepDate.SCALE.YEAR:this.current.setFullYear(this.current.getFullYear()+this.step);break;default:break}}else{switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current=new Date(this.current.valueOf()+this.step);break;case links.Timeline.StepDate.SCALE.SECOND:this.current.setSeconds(this.current.getSeconds()+this.step);break;case links.Timeline.StepDate.SCALE.MINUTE:this.current.setMinutes(this.current.getMinutes()+this.step);break;case links.Timeline.StepDate.SCALE.HOUR:this.current.setHours(this.current.getHours()+this.step);break;case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:this.current.setDate(this.current.getDate()+this.step);break;case links.Timeline.StepDate.SCALE.MONTH:this.current.setMonth(this.current.getMonth()+this.step);break;case links.Timeline.StepDate.SCALE.YEAR:this.current.setFullYear(this.current.getFullYear()+this.step);break;default:break}}if(this.step!=1){switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:if(this.current.getMilliseconds()0){this.step=a}this.autoScale=false};links.Timeline.StepDate.prototype.setAutoScale=function(a){this.autoScale=a};links.Timeline.StepDate.prototype.setMinimumStep=function(f){if(f==undefined){return}var b=(1000*60*60*24*30*12);var a=(1000*60*60*24*30);var e=(1000*60*60*24);var g=(1000*60*60);var d=(1000*60);var h=(1000);var c=(1);if(b*1000>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=1000}if(b*500>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=500}if(b*100>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=100}if(b*50>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=50}if(b*10>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=10}if(b*5>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=5}if(b>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=1}if(a*3>f){this.scale=links.Timeline.StepDate.SCALE.MONTH;this.step=3}if(a>f){this.scale=links.Timeline.StepDate.SCALE.MONTH;this.step=1}if(e*5>f){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=5}if(e*2>f){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=2}if(e>f){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=1}if(e/2>f){this.scale=links.Timeline.StepDate.SCALE.WEEKDAY;this.step=1}if(g*4>f){this.scale=links.Timeline.StepDate.SCALE.HOUR;this.step=4}if(g>f){this.scale=links.Timeline.StepDate.SCALE.HOUR;this.step=1}if(d*15>f){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=15}if(d*10>f){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=10}if(d*5>f){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=5}if(d>f){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=1}if(h*15>f){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=15}if(h*10>f){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=10}if(h*5>f){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=5}if(h>f){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=1}if(c*200>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=200}if(c*100>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=100}if(c*50>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=50}if(c*10>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=10}if(c*5>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=5}if(c>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=1}};links.Timeline.StepDate.prototype.snap=function(a){if(this.scale==links.Timeline.StepDate.SCALE.YEAR){var b=a.getFullYear()+Math.round(a.getMonth()/12);a.setFullYear(Math.round(b/this.step)*this.step);a.setMonth(0);a.setDate(0);a.setHours(0);a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.MONTH){if(a.getDate()>15){a.setDate(1);a.setMonth(a.getMonth()+1)}else{a.setDate(1)}a.setHours(0);a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.DAY||this.scale==links.Timeline.StepDate.SCALE.WEEKDAY){switch(this.step){case 5:case 2:a.setHours(Math.round(a.getHours()/24)*24);break;default:a.setHours(Math.round(a.getHours()/12)*12);break}a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.HOUR){switch(this.step){case 4:a.setMinutes(Math.round(a.getMinutes()/60)*60);break;default:a.setMinutes(Math.round(a.getMinutes()/30)*30);break}a.setSeconds(0);a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.MINUTE){switch(this.step){case 15:case 10:a.setMinutes(Math.round(a.getMinutes()/5)*5);a.setSeconds(0);break;case 5:a.setSeconds(Math.round(a.getSeconds()/60)*60);break;default:a.setSeconds(Math.round(a.getSeconds()/30)*30);break}a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.SECOND){switch(this.step){case 15:case 10:a.setSeconds(Math.round(a.getSeconds()/5)*5);a.setMilliseconds(0);break;case 5:a.setMilliseconds(Math.round(a.getMilliseconds()/1000)*1000);break;default:a.setMilliseconds(Math.round(a.getMilliseconds()/500)*500);break}}else{if(this.scale==links.Timeline.StepDate.SCALE.MILLISECOND){var c=this.step>5?this.step/2:1;a.setMilliseconds(Math.round(a.getMilliseconds()/c)*c)}}}}}}}};links.Timeline.StepDate.prototype.isMajor=function(){switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return(this.current.getMilliseconds()==0);case links.Timeline.StepDate.SCALE.SECOND:return(this.current.getSeconds()==0);case links.Timeline.StepDate.SCALE.MINUTE:return(this.current.getHours()==0)&&(this.current.getMinutes()==0);case links.Timeline.StepDate.SCALE.HOUR:return(this.current.getHours()==0);case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:return(this.current.getDate()==1);case links.Timeline.StepDate.SCALE.MONTH:return(this.current.getMonth()==0);case links.Timeline.StepDate.SCALE.YEAR:return false;default:return false}};links.Timeline.StepDate.prototype.getLabelMinor=function(b,a){if(a==undefined){a=this.current}switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return String(a.getMilliseconds());case links.Timeline.StepDate.SCALE.SECOND:return String(a.getSeconds());case links.Timeline.StepDate.SCALE.MINUTE:return this.addZeros(a.getHours(),2)+":"+this.addZeros(a.getMinutes(),2);case links.Timeline.StepDate.SCALE.HOUR:return this.addZeros(a.getHours(),2)+":"+this.addZeros(a.getMinutes(),2);case links.Timeline.StepDate.SCALE.WEEKDAY:return b.DAYS_SHORT[a.getDay()]+" "+a.getDate();case links.Timeline.StepDate.SCALE.DAY:return String(a.getDate());case links.Timeline.StepDate.SCALE.MONTH:return b.MONTHS_SHORT[a.getMonth()];case links.Timeline.StepDate.SCALE.YEAR:return String(a.getFullYear());default:return""}};links.Timeline.StepDate.prototype.getLabelMajor=function(b,a){if(a==undefined){a=this.current}switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return this.addZeros(a.getHours(),2)+":"+this.addZeros(a.getMinutes(),2)+":"+this.addZeros(a.getSeconds(),2);case links.Timeline.StepDate.SCALE.SECOND:return a.getDate()+" "+b.MONTHS[a.getMonth()]+" "+this.addZeros(a.getHours(),2)+":"+this.addZeros(a.getMinutes(),2);case links.Timeline.StepDate.SCALE.MINUTE:return b.DAYS[a.getDay()]+" "+a.getDate()+" "+b.MONTHS[a.getMonth()]+" "+a.getFullYear();case links.Timeline.StepDate.SCALE.HOUR:return b.DAYS[a.getDay()]+" "+a.getDate()+" "+b.MONTHS[a.getMonth()]+" "+a.getFullYear();case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:return b.MONTHS[a.getMonth()]+" "+a.getFullYear();case links.Timeline.StepDate.SCALE.MONTH:return String(a.getFullYear());default:return""}};links.Timeline.StepDate.prototype.addZeros=function(b,a){var c=""+b;while(c.length=0){d="DOMMouseScroll"}b.addEventListener(d,c,a)}else{b.attachEvent("on"+d,c)}};links.Timeline.removeEventListener=function(b,d,c,a){if(b.removeEventListener){if(a===undefined){a=false}if(d==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0){d="DOMMouseScroll"}b.removeEventListener(d,c,a)}else{b.detachEvent("on"+d,c)}};links.Timeline.getTarget=function(a){if(!a){a=window.event}var b;if(a.target){b=a.target}else{if(a.srcElement){b=a.srcElement}}if(b.nodeType!=undefined&&b.nodeType==3){b=b.parentNode}return b};links.Timeline.stopPropagation=function(a){if(!a){a=window.event}if(a.stopPropagation){a.stopPropagation()}else{a.cancelBubble=true}};links.Timeline.preventDefault=function(a){if(!a){a=window.event}if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}};links.Timeline.getAbsoluteLeft=function(b){var f=document.documentElement;var a=document.body;var d=b.offsetLeft;var c=b.offsetParent;while(c!=null&&c!=a&&c!=f){d+=c.offsetLeft;d-=c.scrollLeft;c=c.offsetParent}return d};links.Timeline.getAbsoluteTop=function(b){var f=document.documentElement;var a=document.body;var d=b.offsetTop;var c=b.offsetParent;while(c!=null&&c!=a&&c!=f){d+=c.offsetTop;d-=c.scrollTop;c=c.offsetParent}return d};links.Timeline.getPageY=function(c){if(("targetTouches" in c)&&c.targetTouches.length){c=c.targetTouches[0]}if("pageY" in c){return c.pageY}var b=c.clientY;var d=document.documentElement;var a=document.body;return b+(d&&d.scrollTop||a&&a.scrollTop||0)-(d&&d.clientTop||a&&a.clientTop||0)};links.Timeline.getPageX=function(c){if(("targetTouches" in c)&&c.targetTouches.length){c=c.targetTouches[0]}if("pageX" in c){return c.pageX}var b=c.clientX;var d=document.documentElement;var a=document.body;return b+(d&&d.scrollLeft||a&&a.scrollLeft||0)-(d&&d.clientLeft||a&&a.clientLeft||0)};links.Timeline.addClassName=function(f,e){var b=f.className.split(" ");var d=e.split(" ");var c=false;for(var a=0;a0){d.on("layoutpaneonresize",$.proxy(function(){this.instance.checkResize()},this))}else{var c="resize.timeline"+PrimeFaces.escapeClientId(this.id);$(window).off(c).on(c,$.proxy(function(){this.instance.checkResize()},this))}}if(this.cfg.opts.selectable&&this.getBehavior("select")){links.events.addListener(this.instance,"select",$.proxy(function(){var f=this.getSelectedIndex();if(f<0){return}var e={params:[{name:this.id+"_eventIdx",value:f}]};this.getBehavior("select").call(this,e)},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.getBehavior("add")){links.events.addListener(this.instance,"add",$.proxy(function(){var e=this.getSelectedEvent();if(e==null){return}var f=[];f.push({name:this.id+"_startDate",value:e.start.getTime()});if(e.end){f.push({name:this.id+"_endDate",value:e.end.getTime()})}if(e.group){f.push({name:this.id+"_group",value:e.group})}this.getBehavior("add").call(this,{params:f})},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.cfg.opts.timeChangeable&&this.getBehavior("change")){links.events.addListener(this.instance,"change",$.proxy(function(){var e=this.getSelectedIndex();if(e<0){return}var f=this.getEvent(e);if(f==null){return}if(!this.instance.isEditable(f)){return}var g=[];g.push({name:this.id+"_eventIdx",value:e});g.push({name:this.id+"_startDate",value:f.start.getTime()});if(f.end){g.push({name:this.id+"_endDate",value:f.end.getTime()})}if(f.group){g.push({name:this.id+"_group",value:f.group})}this.getBehavior("change").call(this,{params:g})},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.cfg.opts.timeChangeable&&this.getBehavior("changed")){links.events.addListener(this.instance,"changed",$.proxy(function(){var e=this.getSelectedIndex();if(e<0){return}var f=this.getEvent(e);if(f==null){return}if(!this.instance.isEditable(f)){return}var g=[];g.push({name:this.id+"_eventIdx",value:e});g.push({name:this.id+"_startDate",value:f.start.getTime()});if(f.end){g.push({name:this.id+"_endDate",value:f.end.getTime()})}if(f.group){g.push({name:this.id+"_group",value:f.group})}this.getBehavior("changed").call(this,{params:g})},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.getBehavior("edit")){links.events.addListener(this.instance,"edit",$.proxy(function(){var f=this.getSelectedIndex();if(f<0){return}if(!this.isEditable(f)){return}var e={params:[{name:this.id+"_eventIdx",value:f}]};this.getBehavior("edit").call(this,e)},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.getBehavior("delete")){links.events.addListener(this.instance,"delete",$.proxy(function(){var f=this.getSelectedIndex();if(f<0){return}if(!this.isEditable(f)){return}var e={params:[{name:this.id+"_eventIdx",value:f}]};this.getBehavior("delete").call(this,e)},this))}if((this.cfg.opts.zoomable||this.cfg.opts.moveable)&&this.getBehavior("rangechange")){links.events.addListener(this.instance,"rangechange",$.proxy(function(){var e=this.instance.getVisibleChartRange();var f={params:[{name:this.id+"_startDate",value:e.start.getTime()},{name:this.id+"_endDate",value:e.end.getTime()}]};this.getBehavior("rangechange").call(this,f)},this))}if((this.cfg.opts.zoomable||this.cfg.opts.moveable)&&this.getBehavior("rangechanged")){links.events.addListener(this.instance,"rangechanged",$.proxy(function(){var e=this.instance.getVisibleChartRange();var f={params:[{name:this.id+"_startDate",value:e.start.getTime()},{name:this.id+"_endDate",value:e.end.getTime()}]};this.getBehavior("rangechanged").call(this,f)},this))}if(this.lazy){this.fireLazyLoading();links.events.addListener(this.instance,"rangechanged",$.proxy(function(){this.fireLazyLoading()},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.getBehavior("drop")){var a={tolerance:"pointer"};if(this.cfg.opts.hoverClass){a.hoverClass=this.cfg.opts.hoverClass}if(this.cfg.opts.activeClass){a.activeClass=this.cfg.opts.activeClass}if(this.cfg.opts.accept){a.accept=this.cfg.opts.accept}if(this.cfg.opts.scope){a.scope=this.cfg.opts.scope}a.drop=$.proxy(function(m,j){var g=this.getInstance();var k=m.pageX-links.Timeline.getAbsoluteLeft(g.dom.content);var i=m.pageY-links.Timeline.getAbsoluteTop(g.dom.content);var n=g.screenToTime(k);var e=g.screenToTime(k+g.size.frameWidth/10);if(this.cfg.opts.snapEvents){g.step.snap(n);g.step.snap(e)}var f=[];f.push({name:this.id+"_startDate",value:n.getTime()});f.push({name:this.id+"_endDate",value:e.getTime()});var l=g.getGroupFromHeight(i);if(l){f.push({name:this.id+"_group",value:g.getGroupName(l)})}f.push({name:this.id+"_dragId",value:j.draggable.attr("id")});var h=j.draggable.closest(".ui-datatable, .ui-datagrid, .ui-datalist, .ui-carousel");if(h.length>0){f.push({name:this.id+"_uiDataId",value:h.attr("id")})}this.getBehavior("drop").call(this,{params:f,event:m,ui:j})},this);$(b).droppable(a)}},getData:function(){var a=$.map(this.instance.getData(),$.proxy(function(c){var b={};if(c.hasOwnProperty("content")){b.data=c.content}if(c.hasOwnProperty("start")){b.startDate=c.start.getTime()}if(c.hasOwnProperty("end")&&(c.end!=null)){b.endDate=c.end.getTime()}else{b.endDate=null}if(c.hasOwnProperty("editable")){b.editable=c.editable}else{b.editable=null}if(c.hasOwnProperty("group")){b.group=c.group}else{b.group=null}if(c.hasOwnProperty("className")){b.styleClass=c.className}else{b.styleClass=null}return b},this));return JSON.stringify(a)},fireLazyLoading:function(){var a=this.getLazyLoadRange();if(a==null){return}var b={params:[]};if(a.startFirst!=null&&a.endFirst!=null){b.params[0]={name:this.id+"_startDateFirst",value:a.startFirst};b.params[1]={name:this.id+"_endDateFirst",value:a.endFirst}}if(a.startSecond!=null&&a.endSecond!=null){b.params[2]={name:this.id+"_startDateSecond",value:a.startSecond};b.params[3]={name:this.id+"_endDateSecond",value:a.endSecond}}this.getBehavior("lazyload").call(this,b)},getLazyLoadRange:function(){var b=this.instance.getVisibleChartRange();if(this.rangeLoadedEvents.start==null||this.rangeLoadedEvents.end==null){var d=(b.end.getTime()-b.start.getTime())*this.pFactor;this.rangeLoadedEvents.start=Math.round(b.start.getTime()-d);this.rangeLoadedEvents.end=Math.round(b.end.getTime()+d);if(this.min!=null&&this.rangeLoadedEvents.startthis.max){this.rangeLoadedEvents.end=this.max}return{startFirst:this.rangeLoadedEvents.start,endFirst:this.rangeLoadedEvents.end,startSecond:null,endSecond:null}}if((b.end.getTime()>this.rangeLoadedEvents.end)&&(b.start.getTime()>=this.rangeLoadedEvents.start)){var g=this.rangeLoadedEvents.end+1;this.rangeLoadedEvents.end=Math.round(b.end.getTime()+(b.end.getTime()-b.start.getTime())*this.pFactor);if(this.max!=null&&this.rangeLoadedEvents.end>this.max){this.rangeLoadedEvents.end=this.max}return{startFirst:g,endFirst:this.rangeLoadedEvents.end,startSecond:null,endSecond:null}}if((b.start.getTime()this.rangeLoadedEvents.end)){var a=(b.end.getTime()-b.start.getTime())*this.pFactor;var e=this.rangeLoadedEvents.start-1;var c=this.rangeLoadedEvents.end+1;this.rangeLoadedEvents.start=Math.round(b.start.getTime()-a);this.rangeLoadedEvents.end=Math.round(b.end.getTime()+a);if(this.min!=null&&this.rangeLoadedEvents.startthis.max){this.rangeLoadedEvents.end=this.max}return{startFirst:this.rangeLoadedEvents.start,endFirst:e,startSecond:c,endSecond:this.rangeLoadedEvents.end}}return null},addEvent:function(a){this.instance.addItem(a)},changeEvent:function(a,b){this.instance.changeItem(a,b)},deleteEvent:function(a,b){this.instance.deleteItem(a,b)},deleteAllEvents:function(){this.instance.deleteAllItems()},cancelAdd:function(){this.instance.cancelAdd()},cancelChange:function(){this.instance.cancelChange()},cancelDelete:function(){this.instance.cancelDelete()},getEvent:function(a){return this.instance.getItem(a)},isEditable:function(a){return this.instance.isEditable(this.getEvent(a))},getVisibleRange:function(){return this.instance.getVisibleChartRange()},setVisibleRange:function(b,a){return this.instance.setVisibleChartRange(b,a)},move:function(a){return this.instance.move(a)},zoom:function(a,b){return this.instance.zoom(a,b)},checkResize:function(){this.instance.checkResize()},getNumberOfEvents:function(){return this.instance.getData().length},getBehavior:function(a){return this.cfg.behaviors?this.cfg.behaviors[a]:null},getSelectedIndex:function(){var a=this.instance.getSelection();if(a.length){if(a[0].row!=undefined){return a[0].row}}return -1},getSelectedEvent:function(){var a=this.getSelectedIndex();if(a!=-1){return this.instance.getItem(a)}return null},setSelection:function(a){if(a>=0){this.instance.setSelection([{row:a}])}else{this.instance.setSelection([])}},getInstance:function(){return this.instance}});